/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _DAL_CYCLONEDDS_QOS_CONVERTER_HPP_
#define _DAL_CYCLONEDDS_QOS_CONVERTER_HPP_

#include <string>
#include "dds/dds.h"
#include "dds/ddsi/ddsi_xqos.h"
#include "dds/ddsi/ddsi_plist.h"
#include "dds/ddsi/ddsi_ipaddr.h"
#include "dal/ret_type.h"
#include "dal/locator.h"
#include "dal/domain_participant.h"

class QosConverter
{
private:
    void AddUnicastLocatorsToWhiteList(SEQUENCE_BASE* seq, dds_qos_t* c_qos);

protected:
    QosConverter();
    static QosConverter* singleton_;

public:
    QosConverter(QosConverter& other) = delete;
    void operator=(const QosConverter&) = delete;
    static QosConverter* GetInstance();

    dal_ret_t SetUnicastToCycloneddsParticipantQos(dal_domain_participant_qos_t *d_qos, std::string &config_str);

    dal_ret_t SetMulticastToCycloneddsParticipantQos(dal_domain_participant_qos_t *d_qos, std::string &config_str);

    dal_ret_t ConvertParticipantQosFromDalToCyclonedds(dal_domain_participant_qos_t* d_qos,
                                                    dds_qos_t* c_qos);

    dal_ret_t ConvertPublisherQosFromDalToCyclonedds(dal_publisher_qos_t* d_qos, dds_qos_t* c_qos);

    dal_ret_t ConvertSubscriberQosFromDalToCyclonedds(dal_subscriber_qos_t* d_qos, dds_qos_t* c_qos);

    dal_ret_t ConvertTopicQosFromDalToCyclonedds(dal_topic_qos_t* d_qos, dds_qos_t* c_qos);

    dal_ret_t ConvertDataWriterQosFromDalToCyclonedds(dal_datawriter_qos_t* d_qos, dds_qos_t* c_qos);

    dal_ret_t ConvertDataReaderQosFromDalToCyclonedds(dal_datareader_qos_t* d_qos, dds_qos_t* c_qos);
};

#endif  // _DAL_CYCLONEDDS_QOS_CONVERTER_HPP_